package o;

import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import com.huawei.appmarket.support.launcher.NoLaunchInterceptor;
import com.huawei.appmarket.support.launcher.VRAppCustomInterceptor;
import com.huawei.appmarket.support.launcher.VRAppDefaultInterceptor;
import o.dky.j;

public final class ced {
    public static <T extends ceg> boolean ˋ(@NonNull Context context, @NonNull String str, String str2, @NonNull T t) {
        Logger.ˎ("AppLauncher", "launch for launching package:[" + str + "]");
        Intent intentByPackage = t.getIntentByPackage(context, str);
        if (intentByPackage != null) {
            return t.launchByPackage(context, intentByPackage, str, str2);
        }
        Logger.ˋ("AppLauncher", "launch for launching package:[" + str + "] failed.intent is null.");
        return false;
    }

    public static boolean ˎ(@NonNull Context context, @NonNull String str, String str2) {
        ceg ॱ = ॱ(context, str, str2);
        ॱ.interceptorResult(str2, context);
        return ॱ.getLaunchResult() == 0;
    }

    public static void ˊ(Context context, String str) {
        if (erz.ˏ(context, str)) {
            Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(str);
            if (launchIntentForPackage != null) {
                context.startActivity(launchIntentForPackage);
                return;
            }
            evk.ˋ(context, context.getResources().getString(j.ˋ, new Object[]{""}), 0).ˋ();
            return;
        }
        ((cdf) cdb.ॱ(cdf.class)).ˎ(str);
        evk.ˏ(context, j.ॱʻ, 0).ˋ();
    }

    private static <T extends ceg> T ॱ(@NonNull Context context, @NonNull String str, String str2) {
        T ˎ;
        if (!erz.ˏ(context, str)) {
            ((cdf) cdb.ॱ(cdf.class)).ˎ(str);
            ˎ = cef.ˎ("default");
            ˎ.setLaunchResult(-1);
            return ˎ;
        } else if (context.getPackageName().equals(str)) {
            ˎ = cef.ˎ("default");
            ˎ.setLaunchResult(2);
            return ˎ;
        } else {
            if (cef.ˏ(str)) {
                ˎ = cef.ˎ(str);
            } else {
                ˎ = cef.ˎ("default");
            }
            if (ˎ.launchByPackage(context, ˎ.getIntentByPackage(context, str), str, str2)) {
                return ˎ;
            }
            ceg vRAppDefaultInterceptor = new VRAppDefaultInterceptor();
            if (vRAppDefaultInterceptor.isInterceptor(str)) {
                return ˊ(context, str, str2, vRAppDefaultInterceptor);
            }
            ˎ = new NoLaunchInterceptor();
            if (ˎ.isInterceptor(str) && ˎ.launchByPackage(context, ˎ.getIntentByPackage(context, str), str, null)) {
                ˎ.setLaunchResult(0);
                return ˎ;
            }
            ˎ.setLaunchResult(1);
            return ˎ;
        }
    }

    private static <T extends ceg> T ˊ(@NonNull Context context, @NonNull String str, String str2, @NonNull T t) {
        int i = 0;
        if (t.launchByPackage(context, t.getIntentByPackage(context, str), str, str2)) {
            t.setLaunchResult(0);
            return t;
        }
        T vRAppCustomInterceptor = new VRAppCustomInterceptor();
        if (!t.launchByPackage(context, t.getIntentByPackage(context, str), str, str2)) {
            i = 1;
        }
        vRAppCustomInterceptor.setLaunchResult(i);
        return vRAppCustomInterceptor;
    }
}
